<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>用户中心_{$web_name}</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="Keywords" content="用户中心" />
		<meta name="Description" content="用户中心" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
		<meta name="format-detection" content="telephone=no">
		<tc_include file="Public:head" />
		<link rel="stylesheet" type="text/css" href="/themes/wnsc/Home/User/css/user.css" />
		<link rel="stylesheet" type="text/css" href="/themes/wnsc/Home/User/css/user_common.css" />
		<style type="text/css">
			.user-right .tabmenu {
				margin-bottom: 0;
			}
			
			.find_con #sflex04 {
				width: 780px;
			}
			
			.find_con .stepflex dl {
				float: left;
				position: relative;
				width: 240px;
				top: -5px;
				border-top: 5px solid #ccc;
				width: 260px!important;
				border-top-color: #cccccc;
			}
			
			.find_con .stepflex dl.doing .s-num {
				background-position: -40px 0;
			}
			
			.find_con .stepflex .s-num {
				position: relative;
				margin: -23px auto 0;
				color: #fff;
				font-weight: 700;
				width: 35px;
				height: 35px;
				background-image: url(/themes/wnsc/Home/User/images/pw_step.png);
				line-height: 35px;
				font-size: 16px;
			}
			
			.find_con .stepflex dl.doing {
				border-top-color: #e31939;
			}
			
			.find_con .stepflex dl.doing .s-text {
				color: #FF0000;
			}
			
			.ncm-default-form h3 {
				font-weight: 600;
				line-height: 22px;
				color: #555;
				clear: both;
				background-color: #F5F5F5;
				padding: 5px 0 5px 12px;
				border-bottom: solid 1px #E7E7E7;
			}
			
			.ncm-default-form dl {
				font-size: 0;
				line-height: 20px;
				clear: both;
				padding: 0;
				margin: 0;
				border-bottom: dotted 1px #E6E6E6;
				overflow: hidden;
			}
			
			.ncm-default-form dl dt {
				width: 19%;
			}
			
			.ncm-default-form dl dt,
			.ncm-default-form dl dd {
				font-size: 12px;
				line-height: 32px;
				vertical-align: top;
				letter-spacing: normal;
				word-spacing: normal;
				text-align: right;
				display: inline-block;
				width: 24%;
				padding: 10px 1% 10px 0;
				margin: 0;
			}
			
			.inputBg {
				float: left;
			}
			
			.common-btn {
				display: inline-block;
			}
			
			.common-btn {
				display: block;
				text-align: center;
				text-decoration: none;
				font-size: 14px;
				width: 120px;
				height: 30px;
				line-height: 30px;
				background: #0689e1;
				margin-right: 25px;
				margin-left: 10px;
				color: #ffffff;
				border: 0;
				cursor: pointer;
				float: left;
			}
			
			.bottom {
				padding: 10px 200px;
			}
			#return_wuliu{
			    width: 49px;
			    height: 29px;
			    background: #000000;
			    border: none;
			    color: #fff;
			}	
		</style>
	</head>

	<body>

		<tc_include file="Public:nav" />
		<div class="w990" id="content" style="background: none;">
			<div class="margin-w1210 clearfix">
				<div class="w">
					<div class="breadcrumb clearfix">
						<a href="/" class="index">首页</a> <span class="crumbs-arrow">&gt;</span> <span class="last">用户中心</span></div>
				</div>
				<div class="blank"></div>
				<tc_include file="Public:user_left" />
				<div class="user-right">
					<div class="box">
						<div class="tabmenu">
							<ul class="tab">
								<li class="active" id="tab1">退款申请</li>
							</ul>
						</div>
						<!-- 提示 -->
						<div class="alert alert-success">
							<h4>操作提示：</h4>
							<ul>
								<li>1. 若您对订单进行支付后想取消购买且与商家达成一致退款，请填写<em>“订单退款”</em>内容并提交。<BR/>2. 订单只有一次退款机会,请谨慎填写。</li>
								
							</ul>
						</div>
						<div class="find_pw3">
							<div class="find_con">
								<div id="sflex04" class="stepflex stepflex_te">
									
									
									<dl class='first doing'>
										<dt class="s-num">1</dt>
										<dd class="s-text"> 买家申请退款<s></s> <b></b> </dd>
									</dl>
									<dl class='normal <egt name="order_info['refund_state']" value="2" >doing</egt>'>
										<dt class="s-num">2</dt>
										<dd class="s-text"> 商家处理退款申请<s></s> <b></b> </dd>
									</dl>

									<dl class="last <egt name="order_info['refund_state']" value="5" >doing</egt>">
										<dt class="s-num">&nbsp;</dt>
										<dd class="s-text"> 退款完成 <s></s> <b></b> </dd>
									</dl>
								</div>
							</div>
						</div>
						
						<div class=" ncm-default-form">
							<div id="warning"></div>

							<h3>如果商家不同意，可以再次申请或投诉。</h3>
							
							<php>if($order_info['refund_state']==0){</php>
							<dl>
								<dt>处理方式：</dt>
								<dd>
									<select id="refund_require" class="inputBg">
										<option value="1" selected="selected">我要退款，但不退货</option>
										<option value="2">我要退款退货</option>
									</select>
								</dd>
							</dl>
							<dl>
								<dt>退款原因：</dt>
								<dd>
									<select id="refund_reason" class="inputBg">
										<option value="买/卖双方协商一致">买/卖双方协商一致</option>
										<option value="买错/多买/不想要">买错/多买/不想要</option>
										<option value="商品质量问题">商品质量问题</option>
										<option value="未收到货品">未收到货品</option>
										<option value="其他">其他</option>
									</select>
								</dd>
							</dl>
							<php>$price=get_count_price($order_info['order_sn']);</php>
							<dl>
								<dt><i class="required">*</i>退款金额：</dt>
								<dd><input id="refund_money" class="maxRefund inputBg" type="text" placeholder="最多可退款{$price}元" onblur="maxRefund()">
									<input value="{$price}" id="maxRefundMoney" type="hidden"> 元</dd>
							</dl>

							<dl id="description_dl" style="display: none;">
								<dt><i class="required">*</i>退款说明：</dt>
								<dd>
									<textarea name="buyer_message" id="description" rows="3" class="textarea w400"></textarea>
									<br>
									<span class="error"></span>
								</dd>
							</dl>

							<div class="bottom">
								<input type="submit" name="submit" class="common-btn" value="确认提交" onclick="btnSave()">
								<a href="javascript:history.go(-1);" class="main-btn main-btn-large">取消并返回</a>
							</div>
							<php>}else{</php>
								<dl>
									<dt>处理方式：</dt>
									
									<dd style="text-align: left;">
										<eq name="order_info['refund_type']" value="1"> 我要退款，但不退货  </eq>
										<eq name="order_info['refund_type']" value="2"> 我要退款退货</eq>
										
									</dd>
								</dl>
								<dl>
									<dt>退款原因：</dt>
									
									<dd style="text-align: left;">
										{$order_info['refund_reason']}
									</dd>
								</dl>
								<dl>
									<dt>*退款金额：</dt>
									
									<dd style="text-align: left;">
										{$order_info['refund_amount']}
										
									</dd>
								</dl>
								<gt name="order_info['refund_state']" value="1">
								<dl>
									<dt>*卖家处理：</dt>
									
									<dd style="text-align: left;width: 500px;">
										<eq name="order_info['refund_state']" value="2"> 同意 </eq>
										<eq name="order_info['refund_state']" value="3"> 店铺拒绝 &nbsp;（官方提示:您还可以联系网站客服处理，{$web_kefu} 周一至周五(9:00-22:00)）</eq>
										<eq name="order_info['refund_state']" value="4"> 等待客服打款</eq>
										<eq name="order_info['refund_state']" value="5"> 打款成功</eq>
									</dd>
								</dl>
								</gt>
								<eq name="order_info['refund_state']" value="2"> 
									<eq name="order_info['refund_type']" value="2">
										<dl >
											<dt>退货物流：</dt>
											<php>$exprsss=get_express();</php>
											<dd style="text-align: left;width: 500px;">
												<select name="exprsss" id="wuliu_express"style="height: 28px;border-color: #ddd;">
													<option value="0">请选择物流公司</option>
													<foreach name="exprsss" item="v">
														<option value="{$v.express_no}" <eq name="order_info['refund_shipping_company_id']" value="$v['express_no']">selected</eq>>{$v.company_name}</option>
													</foreach>
												</select>
												<input class="inputBg wuliu_number" type="text" placeholder="物流单号" value="{$order_info['refund_shipping_code']}">
												<input type="button" name="return_wuliu" id="return_wuliu" value="提交" />
											</dd>
											
										</dl>
									</eq>
								</eq>
								<div class="bottom">
									<a href="javascript:history.go(-1);" class="main-btn main-btn-large">返回列表&gt;&gt;</a>
								</div>
							<php>}</php>
						</div>
					</div>
				</div>

			</div>
		</div>
		<div style="clear: both;"></div>

		<tc_include file="Public:footer" />
		<script type="text/javascript">
			var order_id={$_GET['order_id']};
			$(function() {
				//如果退款原因是选择的其他就让用户自己写退款说明
				$("#refund_reason").change(function() {
					if($(this).val() == "其他") {
						$('#description_dl').show();
					} else {
						$('#description_dl').hide();
					}
				});
				
				$("#return_wuliu").click(function(){
					var wuliu_number=$('.wuliu_number').val();
					var wuliu_express=$('#wuliu_express').val();
					var wuliu_express_name=$("#wuliu_express").find("option:selected").text();
				
					if(!wuliu_number) {
						$(".wuliu_number").focus();
						$.msg("请填写物流单号");
						return false;
					}
					if(wuliu_express==0) {
						$("#wuliu_express").focus();
						$.msg("请选择物流公司");
						return false;
					}
				
					$.ajax({
						url: "{:U('user/refunddetail_update')}",
						type: "post",
						data: {
							"order_id": order_id,
							"wuliu_number": wuliu_number,
							"wuliu_express": wuliu_express,
							"wuliu_express_name": wuliu_express_name,
						},
						dataType: "json",
						success: function(response) {
							if(response.code > 0) {
								$.msg(response.message);
								setTimeout("window.location.reload();",1000)
								
							} else {
								$.msg(response.message);
							}
						}
					});
					
				})

			})
			
			//保存退款信息
			function btnSave() {
				var refund_require = $("#refund_require").val();
				var refund_reason = $("#refund_reason").val();
				var refund_money = $("#refund_money").val(); //退款金额
				var description = $("#description").val(); //
				var maxRefundMoney = parseFloat($("#maxRefundMoney").val());
				if(refund_money != 0) {
					if(refund_money <= 0 || refund_money > maxRefundMoney) {
						$("#refund_money").focus();
						$.msg("超出可退款金额范围");
						return false;
					}
				} else {
					$("#refund_money").focus();
					$.msg("请输入退款金额");
					return false;
				}
				if($('#refund_reason').val() == '其他') {
					refund_reason = description;
				}
				$.ajax({
					url: "{:U('user/refunddetail_save')}",
					type: "post",
					data: {
						"order_id": order_id,
						"refund_type": refund_require,
						"refund_require_money": refund_money,
						"refund_reason": refund_reason,
					},
					dataType: "json",
					success: function(response) {
						if(response.code > 0) {
							$.msg(response.message);
							setTimeout("window.location.reload();",1000)
							
						} else {
							$.msg(response.message);
						}
					}
				});
			}
			function maxRefund(){
				var refund_money = $("#refund_money").val(); //退款金额
				var maxRefundMoney = parseFloat($("#maxRefundMoney").val());
				if(refund_money != 0) {
					if(refund_money <= 0 || refund_money > maxRefundMoney) {
						$("#refund_money").focus();
						$.msg("超出可退款金额范围");
						return false;
					}
				} else {
					$("#refund_money").focus();
					$.msg("请输入退款金额");
					return false;
				}
			}
		</script>
	</body>

</html>